enum AppVersion {
  v0_0_1('0.0.1');

  /// 版本号
  final String version;

  const AppVersion(this.version);

  /// 根据版本号字符串获取对应的枚举值
  static AppVersion? fromVersionString(String? version) {
    if (version == null || version.isEmpty) {
      return null;
    }
    // 遍历所有枚举值，查找版本号匹配的枚举
    for (var v in AppVersion.values) {
      if (v.version == version) {
        return v;
      }
    }
    // 如果没有找到匹配的枚举，返回null
    return null;
  }
}
